package com.ftg.learn.config;

import com.ftg.learn.interceptor.ApiInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置功能
 *
 * @author 布衣
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {




    /**
     * 完成数据接口拦截器类的注入功能
     *
     * @param registry 对应的参数类
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截器类的功能实现
        ApiInterceptor apiInterceptor = new ApiInterceptor();
        //拦截器类的注入功能
        registry.addInterceptor(apiInterceptor)
                // 拦截所有请求
                .addPathPatterns("/api/**");
    }
}
